from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.auth.models import User


class Like(models.Model):

    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey()
    liked = models.ForeignKey(User, on_delete=models.CASCADE, related_name='liked')
    like = models.BooleanField(default=False)
    created = models.DateTimeField(auto_now_add=True)
